package org.qianye.soft;

import org.qianye.soft.stumgr.StudentView;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * 主窗体
 *
 * @author 千叶
 */
public class MainFrame extends JFrame {

	/**
	 * @param splash
	 */
	public MainFrame(SplashWindow splash) {
		init();
	}

	/**
	 * * 构建窗体
	 */
	private void init() {

		setTitle("OMS用户账号查看器");
		setJMenuBar(createMenuBar());
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		setIconImage(Toolkit.getDefaultToolkit().getImage(MainFrame.class.getResource("images/icon.png")));

        Container contentPane = getContentPane();
        contentPane.add(new StudentView(), BorderLayout.CENTER);

		int width = 700, height = 390;
		setSize(width, height);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2);

	}

	/**
	 * 创建菜单栏
	 *
	 * @return JMenuBar
	 */
	private JMenuBar createMenuBar() {
		JMenuBar menuBar = new JMenuBar();

		JMenu menuAbout = new JMenu("关于(A)");
		menuAbout.setMnemonic(KeyEvent.VK_A);

		JMenuItem itemAboutSoft = new JMenuItem("关于本软件");
		itemAboutSoft.addActionListener((e) -> JOptionPane.showMessageDialog(this, "XXX系统\n\t\t" + "分頁Demo!", "关于本软件", JOptionPane.INFORMATION_MESSAGE));

		JMenuItem itemAboutAuthor = new JMenuItem("关于作者");
		itemAboutAuthor.addActionListener((e) -> JOptionPane.showMessageDialog(this, "千叶      " + "基于 JDK1.8 开发!", "关于作者", JOptionPane.INFORMATION_MESSAGE));

		menuAbout.add(itemAboutSoft);
		menuAbout.add(itemAboutAuthor);

		menuBar.add(menuAbout);
		return menuBar;
	}
}
